home *** CD-ROM | disk | FTP | other *** search
- Path: line115.nwm.mindlink.net!user
- From: emery@grebyn.com (David Emery)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: Wed, 10 Apr 1996 20:23:35 +0100
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <emery-1004962023350001@line115.nwm.mindlink.net>
- References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg> <4kb2j8$an0@solutions.solon.com> <dewar.829011320@schonberg> <4kcsnsINNgkb@keats.ugrad.cs.ubc.ca> <dewar.829051685@schonberg> <829066525snz@genesis.demon.co.uk> <dewar.829096975@schonberg>
- NNTP-Posting-Host: line115.nwm.mindlink.net
-
- In article <dewar.829096975@schonberg>, dewar@cs.nyu.edu (Robert Dewar) wrote:
-
- ...
- > What exactly *is* the wording of the POSIX standard here (Lawrence, you
- > must have it at hand, please quote it exactly). The interesting thing
- > is to determine whether this definition says enough to make *any* use
- > of read defined without appealing to "unwritten rules". I would guess
- > not!
-
- I checked today. POSIX.1 (1995 version) is completely silent about
- what happens when the count > the length of buf. I wish I brought my
- standard home, so I could quote it, but it says something like "read transfers
- count characters into the buffer pointed to by buf." The standard
- is completely silent about the characteristics of buf, and one could do
- some 'formal standards reasoning' that says that *any* program that
- depends on the relationship between buf and count is non-compliant, in that
- it is depending on unspecified behavior.
-
- One would have expected for the standard to say something like
- "the buffer pointed to by buf, which is expected to be capable of
- holding at least count bytes..." Oftentimes, POSIX is deliberately silent
- in some areas, particularly error handling, because there was no consensus
- on behavior. Thus any behavior is "undefined", and any implementation is
- 'conforming', regardless of what it does. Personally, I think it's very
- poor standardization practice to be silent in such cases, I'd much prefer
- the standard to explicitly specify such behaviors as 'undefined', to
- warn the user. In this case, I would have preferred for POSIX.1 to say
- "If the size of the storage area pointed to by buf exceeds the value of
- count, the results of any transfer into buf is unspecified."
-
- Additionally, there is no explicit error code identified for "too much
- stuff in the buffer". But POSIX.1 permits implementation extensions in
- such a circumstance, so the Linux implementation is perfectly conforming,
- as are implementations that blindly write into some other address space
- and implementations that detect the fault and immediately send email
- to CJIII and his lawyer :-)
-
- (Even in Ada, writing past the end of an array using unchecked programming
- can result in any sort of behavior, including trashing the boot track of
- the system disk....)
-
- dave
-